﻿picShare.service('getImagesSvc', function (httpRequestSvc, inMemoryDataSvc, imageDataSvc, safeApply, $rootScope) {
    return {
        getImages: function (counter,itemsCount) {
            httpRequestSvc.getJson("http://localhost:26666/api/Image/load-images-from-album?userName="
          + inMemoryDataSvc.currrentUserName + "&albumName=" + inMemoryDataSvc.currrentAlbumName + "&counter=" + counter + "&itemsCount=" + itemsCount).done(
              function (data) {
                  imageDataSvc.imageData = [];
                  imageDataSvc.currentAlbumLength = null;

                  imageDataSvc.imageData = data.images;
                  imageDataSvc.currentAlbumLength = data.albumLength;
                  
                  console.log("from getImageSvc");
                  console.log(imageDataSvc.imageData);
                  console.log(imageDataSvc.currentAlbumLength);

                  safeApply($rootScope);
              }, function (data) {
                  alert(JSON.stringify(data));
              });
        }
    };
});